home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 15 / 015.d81 / a mazing grace (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  3KB  |  122 lines

  1. 100 rem a mazing grace
  2. 110 rem by george trepal
  3. 120 :
  4. 130 poke 56,23:poke 55,215:poke 650,128
  5. 140 dn$="":        pf=0:rem  printer flag
  6. 144 print"[147]do you have a printer ?";
  7. 145 poke198,0:wait198,1:getk$:              ifk$<>"y"andk$<>"n"then147
  8. 146 printk$
  9. 148 ifk$="y"thenpf=1
  10. 149 :
  11. 150 gosub1000
  12. 160 poke53281,0 :poke53280,11: print"[147]"
  13. 170 direc(0)=2:direc(1)=-80:direc(2)=-2:direc(3)=80
  14. 180 wall=160:poke 2,wall: path=32
  15. 190 j=rnd(-ti)
  16. 200 gosub360
  17. 210 rem draw maze
  18. 220 sp$ = "[159]++++++++++++++++++++++++++++++++++++++++"
  19. 230 print"[147]";: for j=1 to 26: print sp$;: next
  20. 240 printdn$;" [153]>>>>>>>>>>>> [158]drawing maze [153]<<<<<<<<<<<<";
  21. 250 now=int(rnd(1)*4):current=now
  22. 260 look = hereiam + direc(now)
  23. 270 if peek(look)=wall then330
  24. 280 now=(now+1): if now>3 then now=0
  25. 290 if now<>current then260
  26. 300 now=peek(hereiam):poke hereiam,path:gosub930
  27. 310 if now<4 then hereiam=hereiam-direc(now): goto250
  28. 320 goto560
  29. 330 pokelook,now:poke hereiam+direc(now)/2,path: hereiam=look:gosub930
  30. 340 goto250
  31. 350 rem user input
  32. 360 sa = 6144
  33. 370 printspc(11)"[147]           giant maze printer"
  34. 380 printspc(12)"by george trepal"
  35. 390 input"    (odd) number of lines (0=exit)";nl:ifnl=0then63000
  36. 400 ifnl/2=int(nl/2) then print "odd numbers only!": goto390
  37. 410 if nl>649 then print "too many lines!": goto390
  38. 412 ifnl<5ornl>670thenprint"not a good sized maze..":fordl=1to1000:next:goto390
  39. 420 print" approximate production time is";int(nl/15*10)/10;"min"
  40. 440 print "  print <1> normal, <2> double or <3>"
  41. 450 input "  triple length maze";flag
  42. 460 if fl<1 or fl>3 then440
  43. 470 ea = nl * 40 + sa - 1
  44. 480 printspc(10)"conditioning memory"
  45. 490 sys 49227
  46. 500 forj = sa - 40 to sa + 39: poke j,102:next
  47. 510 for j = ea - 40 to ea + 40: poke j,102: next
  48. 520 for j = sa-1 to ea step 40: poke j,32: next
  49. 530 hereiam = sa + 77
  50. 540 return
  51. 550 rem finish wall
  52. 560 forj = sa to sa + 38: poke j,wall: next: gosub930
  53. 570 for j = ea - 39 to ea-1: poke j,wall: next: gosub930
  54. 580 poke sa+1,32
  55. 590 poke ea-2,32
  56. 600 ifpf=1thenprintdn$;"     u=up  d=down  p=print x=exit      ";
  57. 602 ifpf=0thenprintdn$;"        u=up   d=down   x=exit         ";
  58. 603 :
  59. 610 goto800
  60. 620 rem output to printer
  61. 630 open4,4: cmd4: f2 = 1
  62. 640 rem print maze
  63. 650 tp = sa:for j = 1 to nl: gosub800
  64. 660 for k = sa to sa + 38
  65. 670 pk = peek (k): if pk = wall then pk = 35
  66. 680 m$ = m$ + chr$(pk) + chr$(pk)
  67. 690 next
  68. 700 m$=" " + m$
  69. 710 for tm = 1 to flag
  70. 720 print#4, m$
  71. 730 next
  72. 740 m$ = "": sa = sa  +40
  73. 750 next
  74. 760 print#4, "   ": close 4
  75. 770 sa=tp: f2 = 0
  76. 780 get a$:if a$<>"" then780
  77. 790 rem show maze
  78. 800 ps=sa:goto860
  79. 810 geta$:ifa$=""then810
  80. 812 ifa$="x"then360
  81. 820 ifa$="u"thenps=ps+40:goto860
  82. 830 ifa$="d"thenps=ps-40:goto860
  83. 840 ifpf=1thenifa$="p"then630
  84. 850 goto810
  85. 860 h=int(ps/256)
  86. 870 l=ps-h*256
  87. 875 ifl<0thenl=0
  88. 876 ifh<0thenh=0
  89. 877 ifl>255thenl=255
  90. 878 ifh>255thenh=255
  91. 880 poke251,l: poke252,h
  92. 890 sys49153
  93. 900 if f2 = 1 then return
  94. 910 goto810
  95. 920 rem fill memory w1th wall
  96. 930 mp=int((hereiam-sa)/40)*40-440
  97. 940 mp=sa + mp
  98. 950 hp = int(mp/256)
  99. 960 lp = mp - 256*hp
  100. 970 poke251,lp: poke252,hp
  101. 980 sys49153:return
  102. 990 rem machine language
  103. 1000 print "[147]": ad = 49152
  104. 1010 read x: if x = -1 then return
  105. 1020 poke ad,x: ad = ad + 1
  106. 1030 goto1010
  107. 1040 data234,234,234,169,0,133,253,169,4,133
  108. 1050 data254,169,0,141,0,192,160,0,162,0
  109. 1060 data177,251,145,253,24,165,251,105,1,133
  110. 1070 data251,165,252,105,0,133,252,24,165,253
  111. 1080 data105,1,133,253,165,254,105,0,133,254
  112. 1090 data232,208,223,234,238,0,192,173,0,192
  113. 1100 data201,4,208,1,96,201,3,208,205,162
  114. 1110 data64,76,20,192,234,169,0,133,251,169
  115. 1120 data24,133,252,160,0,165,2,145,251,200
  116. 1130 data208,251,230,252,165,252,201,126,208,241
  117. 1140 data96,-1
  118. 63000 rem  connect to l.s.
  119. 63005 poke56,160:poke55,0:poke650,0
  120. 63010 print"[147]load"chr$(34)"payload"            chr$(34)",8":print"run"
  121. 63020 poke631,13:poke632,13:poke198,2:        end
  122.